﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using VideoClipNameHelper;

namespace UnitTestProject1
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void Test00()
        {
            Assert.IsFalse(VideoClipNameHelper.VideoClipData.IsNameOK("Bad Company - Rock 'n' Roll Fantasy (promo)"),"1");
            Assert.IsFalse(VideoClipNameHelper.VideoClipData.IsNameOK("Moody Blues - Nights In White Satin (Stage @ Beat Club)"), "2");
            Assert.IsTrue(VideoClipNameHelper.VideoClipData.IsNameOK("Moody Blues - Nights In White Satin (Stage@Beat Club) [352x240+224MP2]"), "3");
            Assert.IsTrue(VideoClipNameHelper.VideoClipData.IsNameOK("Moody Blues - (01) Nights In White Satin (Stage@Beat Club) [352x240+224MP2]"), "4");
            Assert.IsTrue(VideoClipNameHelper.VideoClipData.IsNameOK("Moody Blues - (01) Nights In White Satin (1972)(Stage@Beat Club) [352x240+224MP2]"), "5");
            //Assert.IsTrue(VCNC.IsNameOK("Moody Blues + Nights In White Satin - Stage@Beat Club [352x240+224MP2]"));
            //Assert.IsTrue(VCNC.IsNameOK("Moody-Blues - Nights In White Satin - Stage@Beat Club [352x240+224MP2]"));
        }
        [TestMethod]
        public void Test01()
        {
            VideoClipData vcd = new VideoClipData();
            string sin1 = "Moody-Blues - Nights In White Satin - Stage@Beat Club [352x240+224MP2]";
            Assert.IsTrue("" == VideoClipNameHelper.VideoClipData.Parse(sin1, vcd),"PARSE");
            Assert.AreEqual(vcd.Artist, "Moody-Blues", "ARTIST");
            Assert.AreEqual(vcd.Title, "Nights In White Satin - Stage@Beat Club", "TITLE");
            Assert.AreEqual(vcd.Resolution, "[352x240+224MP2]");
        }
        [TestMethod]
        public void Test02()
        {
            VideoClipData vcd=new VideoClipData();
            string sin1 = "Moody-Blues - Nights In White Satin (Stage@Beat Club) (1999)[352x240+224MP2]";
            Assert.IsTrue("" == VideoClipNameHelper.VideoClipData.Parse(sin1, vcd), "PARSE");
            Assert.AreEqual(vcd.Artist, "Moody-Blues","ARTIST");
            Assert.AreEqual(vcd.Title, "Nights In White Satin","TITLE");
            Assert.AreEqual(vcd.Resolution, "[352x240+224MP2]","R");
            //
            Assert.IsTrue(vcd.TitleExtras.Count == 2, "!= 2", "Count");

            if (2 == vcd.TitleExtras.Count)
            {
                Assert.AreEqual(vcd.TitleExtras[0], "(Stage@Beat Club)");
                Assert.AreEqual(vcd.TitleExtras[1], "(1999)");
            }
        }


        [TestMethod]
        public void Test03()
        {
            //
            //
            string sin1 = "Bee Gees, The - How Can You Mend A Broken Heart [628x480+448AC3_6]";
            string sinOK1 = "Bee Gees, The - How Can You Mend A Broken Heart[628x480+448AC3_6]";
            //string sinOK1 = "Bee Gees, The - How Can You Mend A Broken Heart[628x480+448AC3_6]";
            string sout1 = VideoClipNameHelper.CleanFileName.CleanName(sin1);
            Assert.IsTrue(0 == string.Compare(sinOK1, sout1, true),"|"+sin1+sout1+"|");
            //Assert.AreEqual(sin1, sout1,sout1);
            //
            string sin2 = "Doors, The - Break On Through (To the Other Side)(promo) [720x576+1536PCM]";
            string sinOK2 = "Doors, The - Break On Through(To the Other Side)(promo)[720x576+1536PCM]";
            string sout2 = VideoClipNameHelper.CleanFileName.CleanName(sin2);
            Assert.IsTrue(0 == string.Compare(sinOK2, sout2, true), "|" + sinOK2 + sout2 + "|");
            //Assert.AreEqual(sin2, sout2, "|"+sin2+sout2+"|");
            //
            
            //
        }

        [TestMethod]
        public void Test04()
        {
            //
            string[] testNames = 
            {
"Ace Of Base - The Sign (1994) [720x576+224MP2]",
"Ace of Base - All that she wants [592x448+112MP3]",
"Ace Of Base - All That She Wants [720x480]",
"Ace of Base - The Sign [720x480]",
"Blue Man Group Ft. Dave Matthews - Sing Along (promo) [720x368+192AC3]",
"Co Ro Ft. Tarlisa - Because The Night (1992) [720x480+224MP2]",
"Rolling Stones, The - Around & Around (1965) [720x480+448Ac3_6]",
"Shakira Ft. Carlos Santana - Illegal [720x480]",
"Rolling Stones, The - Around & Around (1965) [720x480+448Ac3_6]"
            };
            //
            VideoClipData vcd = new VideoClipData();
            foreach (string s in testNames)
            {
            Assert.IsTrue("" == VideoClipNameHelper.VideoClipData.Parse(s, vcd),s);
            }
        }

        /*
"D:\Video_AVI_Music\_Clips all\Rolling Stones, The -  (I Can't Get No) Satisfaction (Ed Sullivan Show)(1966) [720x576+224AC3].avi"         
"D:\Video_AVI_Music\_Clips all\Curtis Mayfield -  (Don't Worry) If Theres A Hell Below, Were All Going To Go (1970) [720x480+224MP2].avi"         
         
         
         */
        [TestMethod]
        public void Test05()
        {
            VideoClipData vcd = new VideoClipData();
            string sin1 = "Moody-Blues -  Nights In White Satin (Stage@Beat Club) (1999)[352x240+224MP2]";
            Assert.IsTrue("" == VideoClipNameHelper.VideoClipData.Parse(sin1, vcd), "PARSE");
            Assert.AreEqual(vcd.Artist, "Moody-Blues", "ARTIST");
            Assert.AreEqual(vcd.Title, "Nights In White Satin", "TITLE");
            Assert.AreEqual(vcd.Resolution, "[352x240+224MP2]", "R");
            //
            Assert.IsTrue(vcd.TitleExtras.Count == 2, "!= 2", "Count");

            if (2 == vcd.TitleExtras.Count)
            {
                Assert.AreEqual(vcd.TitleExtras[0], "(Stage@Beat Club)");
                Assert.AreEqual(vcd.TitleExtras[1], "(1999)");
            }
        }

        [TestMethod]
        public void Test06()
        {
            VideoClipData vcd = new VideoClipData();
            string sin1 = "Moody-Blues - (01) Nights In White Satin (Stage@Beat Club) (1999)[352x240+224MP2]";
            Assert.IsTrue("" == VideoClipNameHelper.VideoClipData.Parse(sin1, vcd), "PARSE");
            Assert.AreEqual(vcd.Artist, "Moody-Blues", "ARTIST");
            Assert.AreEqual(vcd.Ordinal, 1, "ORDINAL");
            Assert.AreEqual(vcd.Title, "Nights In White Satin", "TITLE");
            Assert.AreEqual(vcd.Year, 1999, "YEAR");
            Assert.AreEqual(vcd.Resolution, "[352x240+224MP2]", "R");
            //
            Assert.IsTrue(vcd.TitleExtras.Count == 2, "!= 2", "Count");

            if (2 == vcd.TitleExtras.Count)
            {
                Assert.AreEqual(vcd.TitleExtras[0], "(Stage@Beat Club)");
                Assert.AreEqual(vcd.TitleExtras[1], "(1999)");
            }
        }

        [TestMethod]
        public void Test07()
        {
            VideoClipData vcd = new VideoClipData();
            string sin1 = "Jonas Blue Ft Dakota - Fast Car[854x480+125AAC LC]";
            Assert.IsTrue("" == VideoClipNameHelper.VideoClipData.Parse(sin1, vcd), "PARSE");
            Assert.AreEqual(vcd.Artist, "Jonas Blue Ft Dakota", "ARTIST");
            Assert.AreEqual(vcd.Title, "Fast Car", "TITLE");
            Assert.AreEqual(vcd.Resolution, "[854x480+125AAC LC]", "R");
            //
            Assert.IsTrue(vcd.Artists.Count >2, "Artists >2 =="+ vcd.Artists.Count.ToString());

            if (3 == vcd.Artists.Count)
            {
                //Assert.AreEqual(vcd.Artists[0]., "Jonas Blue");
                //Assert.AreEqual(vcd.Artists[2], "Dakota");
            }
        }

        [TestMethod]
        public void Test100()
        {
            System.Collections.Generic.Dictionary<string, string> hintData = new System.Collections.Generic.Dictionary<string, string>();
            GeneralConfig.ParseConfigLines(new System.Collections.Generic.List<string>() { "//", "", " Random=true ", "abacap", "# comment", " XX=YY" }, hintData);
            bool random = GeneralConfig.GetValueBool(hintData, "Random");
            string xx = GeneralConfig.GetValueString(hintData, "xX", "@");
            Assert.IsTrue(random, "Random");
            Assert.AreEqual(xx, "YY", "XX");
        }
        [TestMethod]
        public void Test110()
        {
            string xx = VideoClipNameHelper.Articles.GetNameWithArticle("beatles");
            Assert.AreEqual(xx, "beatles, The", "Beatles, The");
            xx = VideoClipNameHelper.Articles.GetNameWithArticle("Marillion");
            Assert.AreEqual(xx, "Marillion", "Marillion");
        }
        [TestMethod]

        public void Test200()
        {
            VideoClipData vcd = new VideoClipData();
            string fileNameWithExt = "Jonas Blue Ft Dakota - Fast Car(=AltTitle)[854x480+125AAC LC]";
            //
            VideoClipNameHelper.VideoClipData.Parse(fileNameWithExt, vcd);
            //
            System.Collections.Generic.List<VideoFile> sourceVideoFiles = new System.Collections.Generic.List<VideoFile>();
            sourceVideoFiles.Add(new VideoFile(fileNameWithExt+".mkv", true, vcd));
            //
            System.Collections.Generic.List<VideoFile> sourceFilesExpanded = new System.Collections.Generic.List<VideoFile>();
            foreach (VideoFile vf in sourceVideoFiles)
            {
                sourceFilesExpanded.Add(vf);
                //
                if (0 != vf.vcd.AltTitles.Count)
                {
                    foreach (string atitle in vf.vcd.AltTitles)
                    {
                        VideoFile vf1 = new VideoFile(vf);
                        vf1.vcd.Title = atitle;
                        sourceFilesExpanded.Add(vf1);
                    }
                }
                //
                if (vf.vcd.Artists.Count > 1)
                {
                    foreach (string artist in vf.vcd.Artists)
                    {
                            VideoFile vf1 = new VideoFile(vf);
                            vf1.vcd.Artist = artist;
                            sourceFilesExpanded.Add(vf1);
                    }
                }

            }
            Assert.IsTrue(vcd.Artists.Count > 1, "vcd.Artists.Count<2,==" + vcd.Artists.Count.ToString());
            Assert.IsTrue(sourceFilesExpanded.Count==4, "sourceFilesExpanded.Count!=3,=="+ sourceFilesExpanded.Count.ToString());
        }
        //
    }
}
